package com.yanqu.road.server.cmd.strongholdwar.wild;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.strongholdwar.CrossStrongholdMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_STRONGHOLD_WILD_SEARCH,desc = "据点搜索")
public class CrossStrongholdSearchCmd extends CrossUnionCommand {
    private int activityId;
    private long userId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossStrongholdSearchReqMsg req = StrongholdWarProto.CrossStrongholdSearchReqMsg.parseFrom(packet.getBytes());
        activityId = req.getActivityId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        StrongholdWarProto.CrossStrongholdSearchRespMsg.Builder resp = CrossStrongholdMgr.search(activityId, serverId, userId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_STRONGHOLD_WILD_SEARCH, resp);
        MessageHelper.sendPacket(serverId, packet.getPlayerId(), pbMsg);
    }

    @Override
    public void sendData() {

    }
}
